<!DOCTYPE HTML><html>
<head>
<? echo $h->meta($title, $kwd, $dpn); ?>
<? require_once("lib.php"); ?>
<script src="<?=$ecom?>/js/jquery.validate.js" type="text/javascript"></script>
<script src="<?=$ecom?>/js/jquery.metadata.js" type="text/javascript"></script>

</head>
<body id="">
<? include_once("header.php"); ?>
<div id="wrap">
	<div class="breadcrumb">
		<a href="./"><?=WEB_INDEX_PAGE?></a> &gt; <a href="member.html"><?=WEB_MEMBER_CENTER?></a> &gt; <span><?=$cate_name?></span>
	</div><!--breadcrumb end-->
	<div id="" class="w180 left">
		<? require 'member_menu.php' ?>
	</div><!--. w220-->
	<div id="" class="right w760">
		<div class="">
			<div class="h2news">
				<h2><?=$cate_name?></h2>
			</div>
			<?
				$str=''; $k=0;
				if($do=='update'){?>
				<div class="address_b">
				<div class="address_title">
					<div class="right"></div>
					<div clss="left"><strong><?=WEB_ADDRESS_UPDATE?></strong></div>
					<div class="clear"></div>
				</div>
					<div class="address_box">
						<form method="post" class="need_check">
							<input type="hidden" name="action" value="update" />
							<input type="hidden" name="temid" value="<?=$id?>" />
							<input type="hidden" name="refer" value="<?=$refer?>" />
						<table width="100%">
							<tr><td width="120" class="tright"><?=WEB_DELIVERY_TO?>: </td><td><input name="contact_name" value="<?=$info['contact_name']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_DELIVERY_TO_REQUIRED?>'}}}" /></td></tr>
							<tr><td class="tright"><?=WEB_DELIVERY_ADDRESS?>: </td><td>
								<? if($overseas) echo $h->select('country_id',$info['country_id'],$country->get_rows(1024,'','','name_en','asc'),'id','name_'.$lang,'g','ajax_set_province(this.value)');
									else $info['country_id']=1045;
								//else {
									// 省
									if($info['province_id']>0) echo $h->select('province_id',$info['province_id'],$province->get_rows(1024,'country_id',$info['country_id'],'name_en','asc'),'id','name_'.$lang,'g ajax_province','ajax_set_city(this.value)').' &nbsp; ';
									// 市
									if($info['city_id']>0) echo $h->select('city_id',$info['city_id'],$city->get_rows(1024,'province_id',$info['province_id'],'seq_no'),'id','name_'.$lang,'g ajax_city','ajax_set_county(this.value)').' &nbsp; ';
									// 区
									if($info['county_id']>0) echo $h->select('county_id',$info['county_id'],$county->get_rows(10240,'city_id',$info['city_id'],'seq_no'),'id','name_'.$lang,'g ajax_county','').' &nbsp; ';
								 //}
								?>
								<div class="px5"></div>
								<textarea name="street" class="g {validate:{required:true,messages:{required:'<?=WEB_ADDRESS_REQUIRED?>'}}}" cols="24", rows="3"><?=$info['street']?></textarea></td></tr>
							<tr><td class="tright"><?=WEB_ZIP?>: </td><td><input name="zip" value="<?=$info['zip']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_ZIP_REQUIRED?>'}}}" /></td></tr>
							<tr><td class="tright"><?=WEB_CONTACT_NUMBER?>: </td><td><input name="mobile" value="<?=$info['mobile']?>" class="g {validate:{required:true,messages:{required:'<?=WEB_CONTACT_NUMBER_REQUIRED?>'}}}" /></td></tr>
							<tr><td>&nbsp;</td><td>
								<div class="px20"></div>
								<input type="submit" class="button_blue" valud="<?=WEB_UPDATE?>" /> &nbsp; <a href="<? echo $url.'.php'; ?>" class="orange"><?=WEB_CANCEL?></a></td></tr>
						</table><div class="px20"></div>
						</form>
					</div></div><!-- .addressb -->
				<script type="text/javascript">
					var html_no='<option value="0">---<?=WEB_PLEASE_CHOOSE?>---</option>';
					var div_province='.ajax_province';
					var div_city='.ajax_city';
					var div_county='.ajax_county';
					function ajax_set_province(id){
						var div='.ajax_province';
						$.get("ajax_select.php","cate=province&id="+id,function(data){
						if(data=='0') { $(div).empty().fadeOut(); $(div_city).empty().fadeOut();$(div_county).empty().fadeOut();return false; }
						else data=html_no+data;
						$(div).empty().fadeIn();
						$(div_city).empty().fadeOut();
						$(div_county).empty().fadeOut();
						$(data).appendTo(div);
					    });
					}
					function ajax_set_city(id){
						var div='.ajax_city';
						$.get("ajax_select.php","cate=city&id="+id,function(data){
						if(data=='0') { $(div).empty().fadeOut();$(div_county).empty().fadeOut();return false; }
						else data=html_no+data;
						$(div).empty().fadeIn();
						$(data).appendTo(div);
					    });
					}
					function ajax_set_county(id){
						var div='.ajax_county';
						$.get("ajax_select.php","cate=county&id="+id,function(data){
						if(data=='0') { $(div).empty().fadeOut();return false; }
						else data=html_no+data;
						$(div).empty().fadeIn();
						$(data).appendTo(div);
					    });
					}
				</script>
				<?}
				else {
					foreach($info as $val){
						$temid=$val['id'];
						$tem_country=OVERSEA?$country->get_name($val['country_id'],$lang):'';
						$tem_county=$val['county_id']==0?'':$county->get_name($val['county_id'],$lang);
						$tem_city=$val['city_id']==0?'':$city->get_name($val['city_id'],$lang);
						$tem_province=$val['province_id']==0?'':$province->get_name($val['province_id'],$lang);

						$str.='<div class="address_b delete'.$temid.'">
				<div class="address_title">
					<div class="right"><a href="address_book.php?do=update&id='.$temid.'" class="blue">'.WEB_EDIT.'</a> &nbsp; <a onclick="ajax_delete(\'address_book\',\''.$temid.'\')" class="blue">'.WEB_DELETE.'</a></div>
					<div clss="left">';
					if(! $val['is_default']) $str.='<a class="blue" href="address_book.php?do=default&id='.$temid.'">'.WEB_SET_AS_DEFAULT_ADDRESS.'</a>';
					else $str.='<strong>'.WEB_ALREADY_SET_AS_DEFAULT_ADDRESS.'</strong>';
					$str.='</label></div>
					<div class="clear"></div>
				</div>
					<div class="address_box">
						<table width="100%">
							<tr><td width="120" class="tright">'.WEB_DELIVERY_TO.':</td><td>'.$val['contact_name'].'</td></tr>
							<tr><td class="tright">'.WEB_DELIVERY_ADDRESS.':</td><td>'.$tem_country.' '.$tem_province.' '.$tem_city.' '.$tem_county.' '.$val['street'].'</td></tr>
							<tr><td class="tright">'.WEB_ZIP.':</td><td>'.$val['zip'].'</td></tr>
							<tr><td class="tright">'.WEB_CONTACT_NUMBER.':</td><td>'.$val['mobile'].'</td></tr>
						</table>
					</div></div><!-- .addressb -->';
						$k++;
					}
					echo $str;
					// 添加地址
			?>
			<div class="px10" id="add"></div>
			<div class="address_a">
				<div class="address_title_a">
					<div class="right"></div>
					<div clss="left"><strong class="gray"><?=WEB_ADD_DELIVERY_ADDRESS?></strong></div>
					<div class="clear"></div>
				</div>
					<div class="address_box">
						<form method="post" class="need_check">
							<input type="hidden" name="action" value="insert" />
							<input type="hidden" name="temid" value="<?=$id?>" />
							<input type="hidden" name="refer" value="<?=$source?>" />
						<table width="100%">
							<tr><td width="120" class="tright"><?=WEB_DELIVERY_TO?>:</td><td><input name="contact_name" value="" class="g {validate:{required:true,messages:{required:'<?=WEB_DELIVERY_TO_REQUIRED?>'}}}" /></td></tr>
							<tr><td class="tright"><?=WEB_DELIVERY_ADDRESS?>:</td><td>
								<?
								// 省
								$tem=$province->get_rows(1024,'country_id','1045','seq_no');
								$tem[]=array('id'=>0,'name_'.$lang=>'---'.WEB_PLEASE_CHOOSE.'---');
								$tem_mask=array(array('id'=>0,'name_'.$lang=>'---'.WEB_PLEASE_CHOOSE.'---'));

								if($overseas){
									// 海外地区 默认美国
									echo $h->select('country_id','1228',$country->get_rows(1024,'','','name_en','asc'),'id','name_'.$lang,'g','ajax_set_province(this.value)');
									$tem=$province->get_rows(1024,'country_id',1228,'name_en','asc');
									echo $h->select('province_id',0,$tem,'id','name_'.$lang,'g ajax_province','ajax_set_city(this.value)').' &nbsp; ';
									}
								else echo $h->select('province_id',0,$tem,'id','name_'.$lang,'g ajax_province','ajax_set_city(this.value)').' &nbsp; ';
								// 市
								echo $h->select('city_id',0,$tem_mask,'id','name_'.$lang,'hide g ajax_city','ajax_set_county(this.value)').' &nbsp; ';
								// 区
								echo $h->select('county_id',0,$tem_mask,'id','name_'.$lang,'hide g ajax_county','').' &nbsp; ';
								?>
								<div class="px5"></div>
								<textarea name="street" class="g {validate:{required:true,messages:{required:'<?=WEB_ADDRESS_REQUIRED?>'}}}" cols="24", rows="3"></textarea></td></tr>
							<tr><td class="tright"><?=WEB_ZIP?>:</td><td><input name="zip" value="" class="g {validate:{required:true,messages:{required:'<?=WEB_ZIP_REQUIRED?>'}}}" /></td></tr>
							<tr><td class="tright"><?=WEB_CONTACT_NUMBER?>:</td><td><input name="mobile" value="" class="g {validate:{required:true,messages:{required:'<?=WEB_CONTACT_NUMBER_REQUIRED?>'}}}" /></td></tr>
							<tr><td>&nbsp;</td><td>
								<div class="px20"></div>
								<input type="submit" class="button_blue" value="<?=WEB_ADD?>" /></td></tr>
						</table><div class="px20"></div>
						</form>
					</div></div><!-- .addressb -->
				<script type="text/javascript">
					var html_no='<option value="0">---<?=WEB_PLEASE_CHOOSE?>---</option>';
					var div_province='.ajax_province';
					var div_city='.ajax_city';
					var div_county='.ajax_county';
					function ajax_set_province(id){
						var div='.ajax_province';
						$.get("ajax_select.php","cate=province&id="+id,function(data){
						if(data=='0') { $(div).empty().fadeOut(); $(div_city).empty().fadeOut();$(div_county).empty().fadeOut();return false; }
						else data=html_no+data;
						$(div).empty().fadeIn();
						$(div_city).empty().fadeOut();
						$(div_county).empty().fadeOut();
						$(data).appendTo(div);
					    });
					}
					function ajax_set_city(id){
						var div='.ajax_city';
						$.get("ajax_select.php","cate=city&id="+id,function(data){
						if(data=='0') { $(div).empty().fadeOut();$(div_county).empty().fadeOut();return false; }
						else data=html_no+data;
						$(div).empty().fadeIn();
						$(data).appendTo(div);
					    });
					}
					function ajax_set_county(id){
						var div='.ajax_county';
						$.get("ajax_select.php","cate=county&id="+id,function(data){
						if(data=='0') { $(div).empty().fadeOut();return false; }
						else data=html_no+data;
						$(div).empty().fadeIn();
						$(data).appendTo(div);
					    });
					}
				</script>
		<? } ?>
			<div class="clear"></div>
		</div><!--.-->
	</div><!--# featured_and_ad_right-->
	<div class="clear"></div>
	<div class="px20"></div>
	<div class="clear"></div>
</div>
<? include("footer.php"); ?>
<script type="text/javascript">
  $(document).ready(function(){
  	$(".need_check").validate({meta: "validate", onkeyup: false, 
		errorPlacement: function( label, element ) {
			element.parent().append("<br>").append(label);
		}
	});
});
</script>
</body>
</html>